package com.owen.redis.redisson.producer.service.impl;

import com.owen.redis.redisson.producer.entity.Test;
import com.owen.redis.redisson.producer.service.TestService;
import org.redisson.api.RQueue;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private RedissonClient redissonClient;

    @Override
    public Test topic(Test test) {
        RTopic testMq = redissonClient.getTopic("testMq");
        testMq.publish(test);
        return test;
    }

    @Override
    public Test queue(Test test) {
        RQueue testQueue = redissonClient.getQueue("testQueue");
        testQueue.add(test);
//        RTopic testQueue = redissonClient.getTopic("__keyevent@*:del", StringCodec.INSTANCE);
//        testQueue.publish("testQueue");
        return test;
    }

}
